package com.sxu.principles.demo3.after;

// 电脑类进行对Cpu、硬盘、内存进行组合
public class Computer {
    private HardDisk hardDisk;
    private Cpu cpu;
    private Memory memory;

    public HardDisk getHardDisk() {
        return hardDisk;
    }

    public void setHardDisk(HardDisk hardDisk) {
        this.hardDisk = hardDisk;
    }

    public Cpu getCpu() {
        return cpu;
    }

    public void setCpu(Cpu cpu) {
        this.cpu = cpu;
    }

    public Memory getMemory() {
        return memory;
    }

    public void setMemory(Memory memory) {
        this.memory = memory;
    }

    public void run(){
        System.out.println("Computer is running");
        String data = hardDisk.read();
        System.out.println("读取到数据"+data);
        cpu.run();
        memory.save();
    }
}
